package com.bms.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.bms.Logic;
import com.bms.abstracts.RESTController;
import com.bms.domain.Comment;
import com.bms.domain.Event;

public class ViewController extends RESTController {
	
	private Logic logic;
	
	public void setLogic(Logic logic) {
		this.logic = logic;
	}

	@Override
	protected ModelAndView doGet(HttpServletRequest request,
			HttpServletResponse response) {
		String id = request.getParameter("id");
		String userId = request.getParameter("userid");
		
		Event event = logic.getEvent(id);
		
		List<Comment> list = logic.getCommentList(id, userId);
		request.setAttribute("list",list);
		
		
		return new ModelAndView("view","event",event);
	}

	@Override
	protected ModelAndView doPost(HttpServletRequest request,
			HttpServletResponse response) {
		// TODO Auto-generated method stub
		return null;
	}

}
